home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 114_01.zip / CONFIG1.BDS < prev    next >
Text File  |  1993-06-01  |  15KB  |  733 lines

  1. /* Screen editor:  configuration program -- BDS C version
  2.  *
  3.  * Source:  config1.bds
  4.  * Version: December 20, 1981.
  5.  * Transliteration of small-C version of September 6, 1981
  6.  */
  7.  
  8. #define VERSION "Version 2:  September 6, 1981."
  9.  
  10. #include bdscio.h
  11. #include config.h
  12.  
  13.  
  14. /* This program has 5 parts.
  15.  *
  16.  * Part 1 asks which keys do which special functions.
  17.  * Part 2 asks which special functions the screen has.
  18.  * Part 3 asks what code sequences must be output
  19.  *        to the screen to do the functions in part 2.
  20.  * Part 4 creates the file ed1.ccc from the answers to
  21.  *        Part 1.
  22.  * Part 5 creates the file ed6.ccc from the answers to
  23.  *        Parts 2 and 3.
  24.  */
  25.  
  26. main()
  27. {
  28.     /* initialize byte count */
  29.     bytec=0;
  30.     /* sign on and give general information */
  31.     signon();
  32.     /* get keyboard information */
  33.     while (part1()==NO) {
  34.         ;
  35.     }
  36.     /* get screen features */
  37.     while (part2()==NO) {
  38.         ;
  39.     }
  40.     /* get control sequences for screen features */
  41.     while (part3()==NO) {
  42.         ;
  43.     }
  44.     /* make sure we want to continue */
  45.     blank();
  46.     plc("You are now ready to create files ");
  47.     pc("ed1.ccc and ed6.ccc.");
  48.     plc("Do you want to proceed ?");
  49.     if (yesno()==NO) {
  50.         return;
  51.     }
  52.     /* write keyboard info to file ed1.ccc */
  53.     if (part4()!=YES) {
  54.         return;
  55.     }
  56.     /* write control sequences for screen features
  57.      * to file ed6.ccc
  58.      */
  59.     part5();
  60.     /* sign off and tell about compiling */
  61.     signoff();
  62. }
  63.  
  64. /* sign on and tell how to abort */
  65.  
  66. signon()
  67. {
  68. plc("Welcome to the configuration program for the ");
  69. pc("screen editor.");
  70. plc(VERSION);
  71. plc("Hit control-c to exit this program early.");
  72. plc("Hit control-p to send output to the printer.");
  73. }
  74.  
  75. /* part 1.  find out what keys will be used for
  76.  *          special functions.
  77.  */
  78.  
  79. part1()
  80. {
  81.  
  82. blank();
  83. plc("This section deals with your keyboard.");
  84. plc("For each function key, enter the DECIMAL ");
  85. pc("value of the ascii ");
  86. plc("code that you want to assign to that function key.");
  87. plc("Hit carriage return to indicate the default value.");
  88.  
  89. blank();
  90. plc("Hit any key to get more instructions.");
  91. getchar();
  92.  
  93. blank();
  94. plc("insert up key:");
  95. indent();
  96. pc("This key inserts a blank line above the current line,");
  97. indent();
  98. pc("then switches the editor to insert mode.");
  99. indent();
  100. pc("The default is line feed (10).");
  101. up1=getval(10);
  102.  
  103. plc("insert down key:");
  104. indent();
  105. pc("This key inserts a blank line below the current line,");
  106. indent();
  107. pc("then switches the editor to insert mode.");
  108. indent();
  109. pc("The default is carriage return (13).");
  110. down1=getval(13);
  111.  
  112. plc("up key:");
  113. indent();
  114. pc("This key moves the cursor up,");
  115. indent();
  116. pc("then switches the editor to edit mode.");
  117. indent();
  118. pc("The default is control-u (21).");
  119. up2=getval(21);
  120.  
  121. plc("down key:");
  122. indent();
  123. pc("This key moves the cursor down,");
  124. indent();
  125. pc("then switches the editor to edit mode.");
  126. indent();
  127. pc("The default is control-d (4).");
  128. down2=getval(4);
  129.  
  130. plc("left key:");
  131. indent();
  132. pc("This key moves the cursor left. ");
  133. indent();
  134. pc("The default is back space (8).");
  135. left=getval(8);
  136.  
  137. plc("right key:");
  138. indent();
  139. pc("This key moves the cursor right. ");
  140. indent();
  141. pc("The default is control-r (18).");
  142. right=getval(18);
  143.  
  144. plc("insert key:");
  145. indent();
  146. pc("This key switches the editor to insert mode.");
  147. indent();
  148. pc("The default is control-n (14).");
  149. ins=getval(14);
  150.  
  151. plc("edit key:");
  152. indent();
  153. pc("This key switches the editor to edit mode.");
  154. indent();
  155. pc("The default is control-e (5).");
  156. edit=getval(5);
  157.  
  158. plc("command key:");
  159. indent();
  160. pc("This key switches the editor to command mode.");
  161. indent();
  162. pc("The default is esc (27).");
  163. cmnd=getval(27);
  164.  
  165. plc("delete character key:");
  166. indent();
  167. pc("This key deletes the character to the left ");
  168. pc("of the cursor.");
  169. indent();
  170. pc("The default is del (127).");
  171. del=getval(127);
  172.  
  173. plc("delete line key:");
  174. indent();
  175. pc("This key deletes the line on which the cursor rests.");
  176. indent();
  177. pc("The default is control-z (26).");
  178. delline=getval(26);
  179.  
  180. plc("undo key:");
  181. indent();
  182. pc("This key undoes the editing done on a line.");
  183. indent();
  184. pc("The default is control-x (24).");
  185. undo=getval(24);
  186.  
  187. plc("split key:");
  188. indent();
  189. pc("This key splits a line into two lines.");
  190. indent();
  191. pc("The default is control-s (19).");
  192. split=getval(19);
  193.  
  194. plc("join key:");
  195. indent();
  196. pc("This key appends a line to the line above it,");
  197. indent();
  198. pc("then deletes the lower line.");
  199. indent();
  200. pc("The default is control-p (16).");
  201. join=getval(16);
  202.  
  203. /* recap what the user has typed.
  204.  * ask if everything is all right.
  205.  */
  206.  
  207. plc("The values of the keyboard keys are:");
  208. plc("insert up:    ");
  209. putdec(up1,3);
  210. plc("insert down:  ");
  211. putdec(down1,3);
  212. plc("up:           ");
  213. putdec(up2,3);
  214. plc("down:         ");
  215. putdec(down2,3);
  216. plc("left:         ");
  217. putdec(left,3);
  218. plc("right:        ");
  219. putdec(right,3);
  220. plc("insert mode:  ");
  221. putdec(ins,3);
  222. plc("command mode: ");
  223. putdec(cmnd,3);
  224. plc("edit mode:    ");
  225. putdec(edit,3);
  226. plc("delete char:  ");
  227. putdec(del,3);
  228. plc("delete line:  ");
  229. putdec(delline,3);
  230. plc("undo:         ");
  231. putdec(undo,3);
  232. plc("split:        ");
  233. putdec(split,3);
  234. plc("join:         ");
  235. putdec(join,3);
  236. plc("are all values correct ?");
  237. return(yesno());
  238. }
  239.  
  240. /* get features of the video screen */
  241.  
  242. part2()
  243. {
  244.  
  245. blank();
  246. plc("This section deals with the video screen.");
  247. plc("The screen MUST have a cursor positioning function,");
  248. plc("but no other special screen functions are required.");
  249.  
  250. blank();
  251. plc("screen length:");
  252. indent();
  253. pc("How many rows does your screen have ?");
  254. indent();
  255. pc("The default is 16.");
  256. scrnl=getval(16);
  257.  
  258. blank();
  259. plc("screen width:");
  260. indent();
  261. pc("How many columns does your screen have ?");
  262. indent();
  263. pc("The default is 64.");
  264. scrnw=getval(64);
  265.  
  266. blank();
  267. plc("printer width:");
  268. indent();
  269. pc("How many columns does your printer have ?");
  270. indent();
  271. pc("The default is 132.");
  272. lwidth=getval(132);
  273.  
  274. blank();
  275. plc("erase line:");
  276. indent();
  277. pc("Does your screen have a function which erases ");
  278. indent();
  279. pc("the line on which the cursor rests ?");
  280. hasel=yesno();
  281.  
  282. plc("erase to end of line:");
  283. indent();
  284. pc("Does your screen have a function which erases ");
  285. indent();
  286. pc("from the cursor to the end of the line ?");
  287. haseol=yesno();
  288.  
  289. plc("hardware scroll up: (line feed)");
  290. indent();
  291. pc("Does your screen have a function that scrolls the");
  292. indent();
  293. pc("screen up when the cursor is on the bottom line ?");
  294. hassup=yesno();
  295.  
  296. plc("hardware scroll down:");
  297. indent();
  298. pc("Does your screen have a function which scrolls the");
  299. indent();
  300. pc("screen down when the cursor is on the top line ?");
  301. hassdn=yesno();
  302.  
  303. blank();
  304. plc("You have answered as follows: ");
  305. plc("screen length:            ");
  306. putdec(scrnl,1);
  307. plc("screen width:             ");
  308. putdec(scrnw,1);
  309. plc("printer width:            ");
  310. putdec(lwidth,1);
  311. plc("erase line ?              ");
  312. putyesno(hasel);
  313. plc("erase to end of line ?    ");
  314. putyesno(haseol);
  315. plc("hardware scroll up ?      ");
  316. putyesno(hassup);
  317. plc("hardware scroll down ?    ");
  318. putyesno(hassdn);
  319.  
  320. blank();
  321. plc("are all these values correct ?");
  322. return(yesno());
  323. }
  324.  
  325. part3()
  326. {
  327. blank();
  328. plc("This section asks you to supply code sequences for");
  329. plc("the special functions that you said your screen had.");
  330. plc("Enter each sequence one byte at a time.");
  331. plc("End the sequence by typing just a carriage return.");
  332. plc("Indicate each byte by giving a character expression.");
  333. blank();
  334. plc("Hit any character to get more instructions.");
  335. getchar();
  336.  
  337. blank();
  338. plc("An expression consists of terms separated by + or -.");
  339. plc("Each term is either:");
  340. plc("1.  a decimal number or");
  341. plc("2.  an ascii character in single quotes or");
  342. plc("3.  the letters x or y without quotes.");
  343. plc("Use x and y only for the goto xy code sequence.");
  344. plc("The x represents the desired COLUMN for the cursor.");
  345. plc("The y represents the desired ROW    for the cursor.");
  346. plc("For example, a common sequence for goto x y is:");
  347. plc("   27, '=', y+32, x+32");
  348.  
  349. blank();
  350. plc("Warning!  make SURE you specify the row and column in");
  351. plc("the correct order for your terminal.");
  352.  
  353. blank();
  354. plc("Hit any character for more instructions.");
  355. getchar();
  356.  
  357. blank();
  358. plc("goto x y:");
  359. indent();
  360. pc("Enter code to position the cursor at ROW y and COLUMN x.");
  361. indent();
  362. pc("If you mix up x and y, the screen will be gibberish.");
  363. indent();
  364. pc("0,0 is the top left corner of the screen.");
  365. getbytes(&gotoind);
  366.  
  367. blank();
  368. plc("Whew! It gets much easier from here on.");
  369.  
  370. blank();
  371. if (hasel==YES) {
  372.  
  373. plc("erase line:");
  374. indent();
  375. pc("Enter code to erase the line on which the ");
  376. pc("cursor rests.");
  377. getbytes(&elind);
  378.  
  379. }
  380.  
  381. blank();
  382. if (haseol==YES) {
  383.  
  384. plc("erase to end of line:");
  385. indent();
  386. pc("Enter code to erase from the cursor to the ");
  387. pc("end of the line.");
  388. getbytes(&eolind);
  389.  
  390. }
  391.  
  392. blank();
  393. if (hassup==YES) {
  394.  
  395. plc("hardware scroll up: (line feed)");
  396. indent();
  397. pc("Enter code to scroll the screen up assuming ");
  398. indent();
  399. pc("the cursor is on the bottom line.");
  400. getbytes(&supind);
  401.  
  402. }
  403.  
  404. blank();
  405. if (hassdn==YES) {
  406.  
  407. plc("hardware scroll down:");
  408. indent();
  409. pc("Enter code to scroll the screen down assuming ");
  410. indent();
  411. pc("that the cursor is on the top line.");
  412. getbytes(&sdnind);
  413.  
  414. }
  415.  
  416. }
  417.  
  418. part4()
  419. {
  420.  
  421. if (fcreat("ed1.ccc",outbuf)==ERROR) {
  422.     plc("open error on ed1.ccc");
  423.     return(EXIT);
  424. }
  425.  
  426. comment();
  427. plf("Screen editor:  special key definitions");
  428. plf("Source:  ed1.ccc");
  429. plf("This file was created by the configuration program:");
  430. plf(VERSION);
  431. endcom();
  432.  
  433. blankf();
  434. comment();
  435. plf("Define which keys are used for special edit functions.");
  436. endcom();
  437.  
  438. blankf();
  439. putdef("UP1",   up1);
  440. putdef("DOWN1", down1);
  441. putdef("UP2",   up2);
  442. putdef("DOWN2", down2);
  443. putdef("LEFT1", left);
  444. putdef("RIGHT1",right);
  445. putdef("INS1",  ins);
  446. putdef("EDIT1", edit);
  447. putdef("ESC1",  cmnd);
  448. putdef("DEL1",  del);
  449. putdef("ZAP1",  delline);
  450. putdef("ABT1",  undo);
  451. putdef("SPLT1", split);
  452. putdef("JOIN1", join);
  453.  
  454. blankf();
  455. comment();
  456. plf("Define length and width of screen and printer.");
  457. endcom();
  458.  
  459. blankf();
  460. putdef("SCRNW",scrnw);
  461. putdef("SCRNW1",scrnw-1);
  462. putdef("SCRNL",scrnl);
  463. putdef("SCRNL1",scrnl-1);
  464. putdef("SCRNL2",scrnl-2);
  465. putdef("LISTW",lwidth);
  466. blankf();
  467.  
  468. putc(CPMEOF,outbuf);
  469. fflush(outbuf);
  470. fclose(outbuf);
  471. return(YES);
  472. }
  473.  
  474. part5()
  475. {
  476.  
  477. if (fcreat("ed6.ccc",outbuf)==ERROR) {
  478.     plc("Open error on ed6.ccc");
  479.     return(EXIT);
  480. }
  481.  
  482. comment();
  483. plf("Screen editor:  terminal output module");
  484. plf("Source:  ed6.ccc");
  485. plf("This file was created by the configuration program:");
  486. plf(VERSION);
  487. endcom();
  488.  
  489. blankf();
  490. plf("#include ed.h");
  491. plf("#include bdscio.h");
  492. plf("#include ed1.ccc");
  493. plf("#include edext.cc");
  494.  
  495. blankf();
  496. comment();
  497. plf("Define the current coordinates of the cursor.");
  498. endcom();
  499.  
  500. /* comment out -----
  501. blankf();
  502. plf("int outx, outy;");
  503. ----- end comment out */
  504.  
  505. blankf();
  506. comment();
  507. plf("Return the current coordinates of the cursor.");
  508. endcom();
  509.  
  510. blankf();
  511. plf("outgetx()");
  512. beginf();
  513. tab1f(); pf("return(outx);");
  514. endf();
  515.  
  516. blankf();
  517. plf("outgety()");
  518. beginf();
  519. tab1f(); pf("return(outy);");
  520. endf();
  521.  
  522. blankf();
  523. comment();
  524. plf("Output one printable character to the screen.");
  525. endcom();
  526.  
  527. blankf();
  528. plf("outchar(c) char c;");
  529. beginf();
  530. tab1f(); pf("syscout(c);");
  531. tab1f(); pf("outx++;");
  532. tab1f(); pf("return(c);");
  533. endf();
  534.  
  535. blankf();
  536. comment();
  537. plf("Position cursor to position x,y on screen.");
  538. plf("0,0 is the top left corner.");
  539. endcom();
  540.  
  541. blankf();
  542. plf("outxy(x,y) int x,y;");
  543. beginf();
  544. tab1f(); pf("outx=x;");
  545. tab1f(); pf("outy=y;");
  546. putbytes(gotoind);
  547. endf();
  548.  
  549. blankf();
  550. comment();
  551. plf("Erase the entire screen.");
  552. plf("Make sure the rightmost column is erased.");
  553. endcom();
  554.  
  555. blankf();
  556. plf("outclr()");
  557. if ((hasel==YES)+(haseol==YES)) {
  558.  
  559. beginf();
  560. plf("int k;");
  561. tab1f(); pf("k=0;");
  562. tab1f(); pf("while (k<SCRNL) {");
  563. tab2f(); pf("outxy(0,k++);");
  564. tab2f(); pf("outdelln();");
  565. tab1f(); pf("}");
  566. tab1f(); pf("outxy(0,0);");
  567. endf();
  568.  
  569. }
  570. else {
  571.  
  572. beginf();
  573. plf("int k;");
  574. tab1f(); pf("outxy(0,0);");
  575. tab1f(); pf("k=SCRNL*SCRNW;");
  576. tab1f(); pf("while ((k--)>0) {");
  577. tab2f(); pf("syscout(' ');");
  578. tab1f(); pf("}");
  579. tab1f(); pf("outxy(0,0);");
  580. endf();
  581.  
  582. } /* end else */
  583.  
  584. blankf();
  585. comment();
  586. plf("Delete the line on which the cursor rests.");
  587. plf("Leave the cursor at the left margin.");
  588. endcom();
  589.  
  590. blankf();
  591. plf("outdelln()");
  592. if (hasel==YES) {
  593.  
  594. beginf();
  595. putbytes(elind);
  596. endf();
  597.  
  598. }
  599. else {
  600.  
  601. beginf();
  602. tab1f(); pf("outxy(0,outy);");
  603. tab1f(); pf("outdeol();");
  604. endf();
  605.  
  606. }
  607.  
  608. blankf();
  609. comment();
  610. plf("Delete to end of line.");
  611. plf("Assume the last column is blank.");
  612. endcom();
  613.  
  614. blankf();
  615. plf("outdeol()");
  616. if (haseol==YES) {
  617.  
  618. beginf();
  619. putbytes(eolind);
  620. endf();
  621.  
  622. }
  623. else {
  624.  
  625. beginf();
  626. plf("int k;");
  627. tab1f(); pf("k=outx;");
  628. tab1f(); pf("while (k++<SCRNW1) {");
  629. tab2f(); pf("syscout(' ');");
  630. tab1f(); pf("}");
  631. tab1f(); pf("outxy(outx,outy);");
  632. endf();
  633.  
  634. }
  635.  
  636. blankf();
  637. comment();
  638. plf("Return yes if terminal has indicated hardware scroll.");
  639. endcom();
  640.  
  641. blankf();
  642. plf("outhasup()");
  643. beginf();
  644. tab1f();
  645. if (hassup==YES) {
  646.     pf("return(YES);");
  647. }
  648. else {
  649.     pf("return(NO);");
  650. }
  651. endf();
  652.  
  653. blankf();
  654. plf("outhasdn()");
  655. beginf();
  656. tab1f();
  657. if (hassdn==YES) {
  658.     pf("return(YES);");
  659. }
  660. else {
  661.     pf("return(NO);");
  662. }
  663. endf();
  664.  
  665. blankf();
  666. comment();
  667. plf("Scroll the screen up.");
  668. plf("Assume the cursor is on the bottom line.");
  669. endcom();
  670.  
  671. blankf();
  672. plf("outsup()");
  673. if (hassup==YES) {
  674.  
  675. beginf();
  676. tab1f(); pf("/* auto scroll */");
  677. tab1f(); pf("outxy(0,SCRNL1);");
  678. putbytes(supind);
  679. endf();
  680.  
  681. }
  682. else {
  683.  
  684. beginf();
  685. endf();
  686.  
  687. }
  688.  
  689. blankf();
  690. comment();
  691. plf("Scroll screen down.");
  692. plf("Assume the cursor is on the top line.");
  693. endcom();
  694.  
  695. blankf();
  696. plf("outsdn()");
  697. if (hassdn==YES) {
  698.  
  699. beginf();
  700. tab1f(); pf("/* auto scroll */");
  701. tab1f(); pf("outxy(0,0);");
  702. putbytes(sdnind);
  703. endf();
  704.  
  705. }
  706. else {
  707.  
  708. beginf();
  709. endf();
  710.  
  711. }
  712.  
  713. /* make sure last line ends with CR */
  714. plf("");
  715.  
  716. putc(CPMEOF,outbuf);
  717. fflush(outbuf);
  718. fclose(outbuf);
  719. return(YES);
  720. }
  721.  
  722. signoff()
  723. {
  724. plc("The configuration process is now complete.");
  725. plc("You are now ready to compile the screen editor.");
  726. return(YES);
  727. }
  728.  
  729. lf("outhasdn()");
  730. beginf();
  731. tab1f();
  732. if (hassdn==YES) {
  733.     pf("return(YES);"